<template>
	<view>
		<view @click="clickCheck">{{label}}</view>
	</view>
</template>

<script>
export default {
	name:'g-empty',
	data() {
		return {
			parent_com:null,
		};
	},
	props: {
		label:{
			type:String,
		},
		value:{
			type:String
		},
	},
	computed: {
		
	},
	methods: {
		clickCheck(){
			if(this.parent_com.multiple){
				//多选状态下
				let clickIndex = this.parent_com.choicedVal.indexOf(this.value)
				if(clickIndex<0){
					//新增进去
					this.parent_com.choicedVal.push(this.value)
				}else{
					//如果里面有值，那么应该是删除当前选项
					this.parent_com.choicedVal.splice(clickIndex,1)
				}
			}else{
				//单选状态下
				this.parent_com.choicedVal = this.value
			}
			console.log(this.parent_com.choicedVal)
		},
		
	},
	mounted(){
		//H5下有效
		this.parent_com = this.$parent.$parent
		 this.parent_com.checksItems.push(this)
	},
	created() {
	}
};
</script>
<style></style>
